#!/usr/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

date=$(date)
/usr/bin/mkdir -p /data/logs/yaml_sync

echo "Yaml sync at $date" >> /data/logs/yaml_sync/yaml_sync.log
microservices="microservice1\
               microservice2\
               microservice3"
yaml_root=/opt/soft/microservices/openapi3-doc/yaml
microservice_root=/opt/soft/microservice_tools/deploy/microservices

for ms in $microservices
do
    echo "sync $microservice_root/${ms}/${ms}.yaml"
    cd $microservice_root/${ms}
    /usr/bin/git pull
    \cp -f ${ms}.yaml $yaml_root
done

# echo "重启openapi3-doc服务..."
# /usr/bin/supervisorctl restart openapi3-doc
# echo "重启openapi3-doc服务ok"

echo "Yaml sync OK" >> /data/logs/yaml_sync/yaml_sync.log
echo "" >> /data/logs/yaml_sync/yaml_sync.log
